//引入mysql
const mysql = require('mysql')
//创建conObj
let conObj = mysql.createConnection({
    user:'root',
    host:'localhost',
    password:'root',
    port:'3306',
    database:'U_online_course'
})

function Query(sqlStr = ``){
    return new Promise((resolve,reject)=>{
        conObj.query(sqlStr,(err,res)=>{
            if(!err){
                resolve([null,res])
            }else{
                resolve([err])
            }
        })
    })
}

//暴露
module.exports = Query